Skip to main content

Socket

Introduction

A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port number so that the TCP layer can identify the application that data is destined to be sent to.

Prerequisite: socket example.zip

Donwload socket example.zip

This zip file should contain;

  1. Node_modules folder
  2. Automobile.json
  3. Change.html
  4. Change.js
  5. Index.html
  6. package-lock.json
  7. Server.js

Moreover, you should have dashboard for socket and its databases, Upload Dataset first in to OPNBI and Dashboard afterwards.

Once dashboard uploaded successfully, open command prompt and change path to folder containing Serve.js file.

Docusaurus Slash Introduction

Run this command: ‘node server.js’ from here.

By executing this command, node server will start. To check this open browser and write ‘localhost:5002’ and hit enter. You will see the screen like below:

Docusaurus Slash Introduction

Once this screen available, open new tab and enter url ‘localhost:5002/change’ and hit Enter

Docusaurus Slash Introduction

To start socket, click on start button. Once you click on start you can see socket status changed to Started and Socket id is available as seen in below image

Docusaurus Slash Introduction

-Go to the previous tab and you can see data is refreshing. This means socket is working.

-Go to OPNBI and open socket dashboard you have uploaded and see widget data are updating frequently.